<template>
  <div>
    <el-table
      :data="list"
      style="width: 100%"
      row-key="id"
      border
      :tree-props="{children: 'children'}"
    >
      <el-table-column prop="id" label="分类编号" width="180"></el-table-column>
      <el-table-column prop="catename" label="分类名称"></el-table-column>
      <el-table-column  label="图片">
        <template slot-scope="scope">
           <img :src="$pre+scope.row.img" alt="">
        </template>
       
      </el-table-column>
      <el-table-column label="状态">
        <template slot-scope="scope">
          <el-button type="primary" v-if="scope.row.status==1">启用</el-button>
          <el-button type="info" v-else>禁用</el-button>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="primary" @click="willEdit(scope.row.id)">编辑</el-button>
          <el-button type="denger" @click="del(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import {successAlert} from "../../../utils/alert";
import { mapGetters, mapActions } from "vuex";
import { reqroledelete,reqcatedelete } from "../../../request/api";
export default {
  components: {},
  computed: {
    ...mapGetters({
      list:"cate/list"
    }),
  },
  methods: {
    ...mapActions({
      reqList:"cate/reqList"
    }),
    //将要编辑
    willEdit(id) {
      this.$emit("edit", id);
    },
    //将要删除
    del(id) {
      reqcatedelete({ id: id }).then((res) => {
        if (res.data.code == 200) {
          //弹框
          successAlert(res.data.msg);
          //刷新
          this.reqList();
        }
      });
    },
  },
  mounted() {
    this.reqList()
  },
  props: [],
  data() {
    return {
      tableData: [],
      imgUrl:null
    };
  },
};
</script>
<style lang="less" scoped>
img{
  width:100px;
}
</style>